﻿#region Using directives

using System;
using System.Data;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;

using Indeco.G24.Entities;
using Indeco.G24.Data;

#endregion

namespace Indeco.G24.Data.Bases
{	
	///<summary>
	/// This class is the base class for any <see cref="TinTucTieuDiemProviderBase"/> implementation.
	/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
	///</summary>
	public abstract partial class TinTucTieuDiemProviderBaseCore : EntityProviderBase<Indeco.G24.Entities.TinTucTieuDiem, Indeco.G24.Entities.TinTucTieuDiemKey>
	{		
		#region Get from Many To Many Relationship Functions
		#endregion	
		
		#region Delete Methods

		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to delete.</param>
		/// <returns>Returns true if operation suceeded.</returns>
		public override bool Delete(TransactionManager transactionManager, Indeco.G24.Entities.TinTucTieuDiemKey key)
		{
			return Delete(transactionManager, key.IDTinTucDanhMuc, key.IDTinTuc);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="iDTinTucDanhMuc">. Primary Key.</param>
		/// <param name="iDTinTuc">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public bool Delete(System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc)
		{
			return Delete(null, iDTinTucDanhMuc, iDTinTuc);
		}
		
		/// <summary>
		/// 	Deletes a row from the DataSource.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc">. Primary Key.</param>
		/// <param name="iDTinTuc">. Primary Key.</param>
		/// <remarks>Deletes based on primary key(s).</remarks>
		/// <returns>Returns true if operation suceeded.</returns>
		public abstract bool Delete(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc);		
		
		#endregion Delete Methods
		
		#region Get By Foreign Key Functions
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTuc Description: 
		/// </summary>
		/// <param name="iDTinTuc"></param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(System.Guid iDTinTuc)
		{
			int count = -1;
			return GetByIDTinTuc(iDTinTuc, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTuc"></param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		/// <remarks></remarks>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTuc)
		{
			int count = -1;
			return GetByIDTinTuc(transactionManager, iDTinTuc, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDTinTuc(transactionManager, iDTinTuc, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		fKTbTinTucTieuDiemTbTinTuc Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDTinTuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(System.Guid iDTinTuc, int start, int pageLength)
		{
			int count =  -1;
			return GetByIDTinTuc(null, iDTinTuc, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		fKTbTinTucTieuDiemTbTinTuc Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDTinTuc"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(System.Guid iDTinTuc, int start, int pageLength,out int count)
		{
			return GetByIDTinTuc(null, iDTinTuc, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public abstract Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTuc, int start, int pageLength, out int count);
		
	
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc Description: 
		/// </summary>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(System.Guid iDTinTucDanhMuc)
		{
			int count = -1;
			return GetByIDTinTucDanhMuc(iDTinTucDanhMuc, 0,int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		/// <remarks></remarks>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc)
		{
			int count = -1;
			return GetByIDTinTucDanhMuc(transactionManager, iDTinTucDanhMuc, 0, int.MaxValue, out count);
		}
		
			/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		///  <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDTinTucDanhMuc(transactionManager, iDTinTucDanhMuc, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		fKTbTinTucTieuDiemTbTinTucDanhMuc Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(System.Guid iDTinTucDanhMuc, int start, int pageLength)
		{
			int count =  -1;
			return GetByIDTinTucDanhMuc(null, iDTinTucDanhMuc, start, pageLength,out count);	
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		fKTbTinTucTieuDiemTbTinTucDanhMuc Description: 
		/// </summary>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(System.Guid iDTinTucDanhMuc, int start, int pageLength,out int count)
		{
			return GetByIDTinTucDanhMuc(null, iDTinTucDanhMuc, start, pageLength, out count);	
		}
						
		/// <summary>
		/// 	Gets rows from the datasource based on the FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc key.
		///		FK_tb_TinTucTieuDiem_tb_TinTucDanhMuc Description: 
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns a typed collection of Indeco.G24.Entities.TinTucTieuDiem objects.</returns>
		public abstract Indeco.G24.Entities.TList<TinTucTieuDiem> GetByIDTinTucDanhMuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, int start, int pageLength, out int count);
		
		#endregion

		#region Get By Index Functions
		
		/// <summary>
		/// 	Gets a row from the DataSource based on its primary key.
		/// </summary>
		/// <param name="transactionManager">A <see cref="TransactionManager"/> object.</param>
		/// <param name="key">The unique identifier of the row to retrieve.</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <returns>Returns an instance of the Entity class.</returns>
		public override Indeco.G24.Entities.TinTucTieuDiem Get(TransactionManager transactionManager, Indeco.G24.Entities.TinTucTieuDiemKey key, int start, int pageLength)
		{
			return GetByIDTinTucDanhMucIDTinTuc(transactionManager, key.IDTinTucDanhMuc, key.IDTinTuc, start, pageLength);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the primary key PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc)
		{
			int count = -1;
			return GetByIDTinTucDanhMucIDTinTuc(null,iDTinTucDanhMuc, iDTinTuc, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDTinTucDanhMucIDTinTuc(null, iDTinTucDanhMuc, iDTinTuc, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc)
		{
			int count = -1;
			return GetByIDTinTucDanhMucIDTinTuc(transactionManager, iDTinTucDanhMuc, iDTinTuc, 0, int.MaxValue, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc, int start, int pageLength)
		{
			int count = -1;
			return GetByIDTinTucDanhMucIDTinTuc(transactionManager, iDTinTucDanhMuc, iDTinTuc, start, pageLength, out count);
		}
		
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">out parameter to get total records for query</param>
		/// <remarks></remarks>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc, int start, int pageLength, out int count)
		{
			return GetByIDTinTucDanhMucIDTinTuc(null, iDTinTucDanhMuc, iDTinTuc, start, pageLength, out count);
		}
		
				
		/// <summary>
		/// 	Gets rows from the datasource based on the PK_tb_TinTucTieuDiem index.
		/// </summary>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="iDTinTucDanhMuc"></param>
		/// <param name="iDTinTuc"></param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">Number of rows to return.</param>
		/// <param name="count">The total number of records.</param>
		/// <returns>Returns an instance of the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> class.</returns>
		public abstract Indeco.G24.Entities.TinTucTieuDiem GetByIDTinTucDanhMucIDTinTuc(TransactionManager transactionManager, System.Guid iDTinTucDanhMuc, System.Guid iDTinTuc, int start, int pageLength, out int count);
						
		#endregion "Get By Index Functions"
	
		#region Custom Methods
		
		
		#endregion

		#region Helper Functions	
		
		/// <summary>
		/// Fill a Indeco.G24.Entities.TList&lt;TinTucTieuDiem&gt; From a DataReader.
		/// </summary>
		/// <param name="reader">Datareader</param>
		/// <param name="rows">The collection to fill</param>
		/// <param name="start">Row number at which to start reading, the first row is 0.</param>
		/// <param name="pageLength">number of rows.</param>
		/// <returns>a <see cref="Indeco.G24.Entities.TList&lt;TinTucTieuDiem&gt;"/></returns>
		public static Indeco.G24.Entities.TList<TinTucTieuDiem> Fill(IDataReader reader, Indeco.G24.Entities.TList<TinTucTieuDiem> rows, int start, int pageLength)
		{
		// advance to the starting row
		for (int i = 0; i < start; i++)
		{
			if (!reader.Read())
			return rows; // not enough rows, just return
		}
		for (int i = 0; i < pageLength; i++)
		{
			if (!reader.Read())
			break; // we are done
			string key = null;
			
			Indeco.G24.Entities.TinTucTieuDiem c = null;
			if (DataRepository.Provider.UseEntityFactory)
			{
			key = new System.Text.StringBuilder("TinTucTieuDiem")
			.Append("|").Append((reader.IsDBNull(((int)Indeco.G24.Entities.TinTucTieuDiemColumn.IDTinTucDanhMuc - 1))?Guid.Empty:(System.Guid)reader[((int)Indeco.G24.Entities.TinTucTieuDiemColumn.IDTinTucDanhMuc - 1)]).ToString())
			.Append("|").Append((reader.IsDBNull(((int)Indeco.G24.Entities.TinTucTieuDiemColumn.IDTinTuc - 1))?Guid.Empty:(System.Guid)reader[((int)Indeco.G24.Entities.TinTucTieuDiemColumn.IDTinTuc - 1)]).ToString()).ToString();
			c = EntityManager.LocateOrCreate<TinTucTieuDiem>(
			key.ToString(), // EntityTrackingKey
			"TinTucTieuDiem",  //Creational Type
			DataRepository.Provider.EntityCreationalFactoryType,  //Factory used to create entity
			DataRepository.Provider.EnableEntityTracking); // Track this entity?
			}
			else
			{
			c = new Indeco.G24.Entities.TinTucTieuDiem();
			}
			
			if (!DataRepository.Provider.EnableEntityTracking ||
			c.EntityState == EntityState.Added ||
			(DataRepository.Provider.EnableEntityTracking &&
			((DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.PreserveChanges && c.EntityState == EntityState.Unchanged) ||
			(DataRepository.Provider.CurrentLoadPolicy == LoadPolicy.DiscardChanges && (c.EntityState == EntityState.Unchanged ||
								c.EntityState == EntityState.Changed)))))
						{
			c.SuppressEntityEvents = true;
			c.IDTinTucDanhMuc = (System.Guid)reader["ID_TinTucDanhMuc"];
			c.OriginalIDTinTucDanhMuc = c.IDTinTucDanhMuc;
			c.IDTinTuc = (System.Guid)reader["ID_TinTuc"];
			c.OriginalIDTinTuc = c.IDTinTuc;
			c.EntityTrackingKey = key;
			c.AcceptChanges();
			c.SuppressEntityEvents = false;
			}
			rows.Add(c);
		}
		return rows;
		}		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> object from the <see cref="IDataReader"/>.
		/// </summary>
		/// <param name="reader">The <see cref="IDataReader"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> object to refresh.</param>
		public static void RefreshEntity(IDataReader reader, Indeco.G24.Entities.TinTucTieuDiem entity)
		{
			if (!reader.Read()) return;
			
			entity.IDTinTucDanhMuc = (System.Guid)reader["ID_TinTucDanhMuc"];
			entity.OriginalIDTinTucDanhMuc = (System.Guid)reader["ID_TinTucDanhMuc"];
			entity.IDTinTuc = (System.Guid)reader["ID_TinTuc"];
			entity.OriginalIDTinTuc = (System.Guid)reader["ID_TinTuc"];
			entity.AcceptChanges();
		}
		
		/// <summary>
		/// Refreshes the <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> object from the <see cref="DataSet"/>.
		/// </summary>
		/// <param name="dataSet">The <see cref="DataSet"/> to read from.</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> object.</param>
		public static void RefreshEntity(DataSet dataSet, Indeco.G24.Entities.TinTucTieuDiem entity)
		{
			DataRow dataRow = dataSet.Tables[0].Rows[0];
			
			entity.IDTinTucDanhMuc = (System.Guid)dataRow["ID_TinTucDanhMuc"];
			entity.OriginalIDTinTucDanhMuc = (System.Guid)dataRow["ID_TinTucDanhMuc"];
			entity.IDTinTuc = (System.Guid)dataRow["ID_TinTuc"];
			entity.OriginalIDTinTuc = (System.Guid)dataRow["ID_TinTuc"];
			entity.AcceptChanges();
		}
		#endregion 
		
		#region DeepLoad Methods
		/// <summary>
		/// Deep Loads the <see cref="IEntity"/> object with criteria based of the child 
		/// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
		/// </summary>
		/// <remarks>
		/// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
		/// </remarks>
		/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
		/// <param name="entity">The <see cref="Indeco.G24.Entities.TinTucTieuDiem"/> object to load.</param>
		/// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
		/// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
		/// <param name="childTypes">Indeco.G24.Entities.TinTucTieuDiem Property Collection Type Array To Include or Exclude from Load</param>
		/// <param name="innerList">A collection of child types for easy access.</param>
	    /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
	    /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
		internal override void DeepLoad(TransactionManager transactionManager, Indeco.G24.Entities.TinTucTieuDiem entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
		{
			if(entity == null)
				return;

			#region IDTinTucSource	
			if (CanDeepLoad(entity, "TinTuc|IDTinTucSource", deepLoadType, innerList) 
				&& entity.IDTinTucSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IDTinTuc;
				TinTuc tmpEntity = EntityManager.LocateEntity<TinTuc>(EntityLocator.ConstructKeyFromPkItems(typeof(TinTuc), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IDTinTucSource = tmpEntity;
				else
					entity.IDTinTucSource = DataRepository.TinTucProvider.GetByIDTinTuc(transactionManager, entity.IDTinTuc);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IDTinTucSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IDTinTucSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.TinTucProvider.DeepLoad(transactionManager, entity.IDTinTucSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IDTinTucSource

			#region IDTinTucDanhMucSource	
			if (CanDeepLoad(entity, "TinTucDanhMuc|IDTinTucDanhMucSource", deepLoadType, innerList) 
				&& entity.IDTinTucDanhMucSource == null)
			{
				object[] pkItems = new object[1];
				pkItems[0] = entity.IDTinTucDanhMuc;
				TinTucDanhMuc tmpEntity = EntityManager.LocateEntity<TinTucDanhMuc>(EntityLocator.ConstructKeyFromPkItems(typeof(TinTucDanhMuc), pkItems), DataRepository.Provider.EnableEntityTracking);
				if (tmpEntity != null)
					entity.IDTinTucDanhMucSource = tmpEntity;
				else
					entity.IDTinTucDanhMucSource = DataRepository.TinTucDanhMucProvider.GetByIDTinTucDanhMuc(transactionManager, entity.IDTinTucDanhMuc);		
				
				#if NETTIERS_DEBUG
				System.Diagnostics.Debug.WriteLine("- property 'IDTinTucDanhMucSource' loaded. key " + entity.EntityTrackingKey);
				#endif 
				
				if (deep && entity.IDTinTucDanhMucSource != null)
				{
					innerList.SkipChildren = true;
					DataRepository.TinTucDanhMucProvider.DeepLoad(transactionManager, entity.IDTinTucDanhMucSource, deep, deepLoadType, childTypes, innerList);
					innerList.SkipChildren = false;
				}
					
			}
			#endregion IDTinTucDanhMucSource
			
			//used to hold DeepLoad method delegates and fire after all the local children have been loaded.
			Dictionary<string, KeyValuePair<Delegate, object>> deepHandles = new Dictionary<string, KeyValuePair<Delegate, object>>();
			
			//Fire all DeepLoad Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles.Values)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			deepHandles = null;
		}
		
		#endregion 
		
		#region DeepSave Methods

		/// <summary>
		/// Deep Save the entire object graph of the Indeco.G24.Entities.TinTucTieuDiem object with criteria based of the child 
		/// Type property array and DeepSaveType.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entity">Indeco.G24.Entities.TinTucTieuDiem instance</param>
		/// <param name="deepSaveType">DeepSaveType Enumeration to Include/Exclude object property collections from Save.</param>
		/// <param name="childTypes">Indeco.G24.Entities.TinTucTieuDiem Property Collection Type Array To Include or Exclude from Save</param>
		/// <param name="innerList">A Hashtable of child types for easy access.</param>
		internal override bool DeepSave(TransactionManager transactionManager, Indeco.G24.Entities.TinTucTieuDiem entity, DeepSaveType deepSaveType, System.Type[] childTypes, DeepSession innerList)
		{	
			if (entity == null)
				return false;
							
			#region Composite Parent Properties
			//Save Source Composite Properties, however, don't call deep save on them.  
			//So they only get saved a single level deep.
			
			#region IDTinTucSource
			if (CanDeepSave(entity, "TinTuc|IDTinTucSource", deepSaveType, innerList) 
				&& entity.IDTinTucSource != null)
			{
				DataRepository.TinTucProvider.Save(transactionManager, entity.IDTinTucSource);
				entity.IDTinTuc = entity.IDTinTucSource.IDTinTuc;
			}
			#endregion 
			
			#region IDTinTucDanhMucSource
			if (CanDeepSave(entity, "TinTucDanhMuc|IDTinTucDanhMucSource", deepSaveType, innerList) 
				&& entity.IDTinTucDanhMucSource != null)
			{
				DataRepository.TinTucDanhMucProvider.Save(transactionManager, entity.IDTinTucDanhMucSource);
				entity.IDTinTucDanhMuc = entity.IDTinTucDanhMucSource.IDTinTucDanhMuc;
			}
			#endregion 
			#endregion Composite Parent Properties

			// Save Root Entity through Provider
			if (!entity.IsDeleted)
				this.Save(transactionManager, entity);
			
			//used to hold DeepSave method delegates and fire after all the local children have been saved.
			Dictionary<Delegate, object> deepHandles = new Dictionary<Delegate, object>();
			//Fire all DeepSave Items
			foreach(KeyValuePair<Delegate, object> pair in deepHandles)
		    {
                pair.Key.DynamicInvoke((object[])pair.Value);
		    }
			
			// Save Root Entity through Provider, if not already saved in delete mode
			if (entity.IsDeleted)
				this.Save(transactionManager, entity);
				

			deepHandles = null;
						
			return true;
		}
		#endregion
	} // end class
	
	#region TinTucTieuDiemChildEntityTypes
	
	///<summary>
	/// Enumeration used to expose the different child entity types 
	/// for child properties in <c>Indeco.G24.Entities.TinTucTieuDiem</c>
	///</summary>
	public enum TinTucTieuDiemChildEntityTypes
	{
		
		///<summary>
		/// Composite Property for <c>TinTuc</c> at IDTinTucSource
		///</summary>
		[ChildEntityType(typeof(TinTuc))]
		TinTuc,
			
		///<summary>
		/// Composite Property for <c>TinTucDanhMuc</c> at IDTinTucDanhMucSource
		///</summary>
		[ChildEntityType(typeof(TinTucDanhMuc))]
		TinTucDanhMuc,
		}
	
	#endregion TinTucTieuDiemChildEntityTypes
	
	#region TinTucTieuDiemFilterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="SqlFilterBuilder&lt;TinTucTieuDiemColumn&gt;"/> class
	/// that is used exclusively with a <see cref="TinTucTieuDiem"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class TinTucTieuDiemFilterBuilder : SqlFilterBuilder<TinTucTieuDiemColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemFilterBuilder class.
		/// </summary>
		public TinTucTieuDiemFilterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public TinTucTieuDiemFilterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemFilterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public TinTucTieuDiemFilterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion TinTucTieuDiemFilterBuilder
	
	#region TinTucTieuDiemParameterBuilder
	
	/// <summary>
	/// A strongly-typed instance of the <see cref="ParameterizedSqlFilterBuilder&lt;TinTucTieuDiemColumn&gt;"/> class
	/// that is used exclusively with a <see cref="TinTucTieuDiem"/> object.
	/// </summary>
	[CLSCompliant(true)]
	public class TinTucTieuDiemParameterBuilder : ParameterizedSqlFilterBuilder<TinTucTieuDiemColumn>
	{
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemParameterBuilder class.
		/// </summary>
		public TinTucTieuDiemParameterBuilder() : base() { }

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		public TinTucTieuDiemParameterBuilder(bool ignoreCase) : base(ignoreCase) { }

		/// <summary>
		/// Initializes a new instance of the TinTucTieuDiemParameterBuilder class.
		/// </summary>
		/// <param name="ignoreCase">Specifies whether to create case-insensitive statements.</param>
		/// <param name="useAnd">Specifies whether to combine statements using AND or OR.</param>
		public TinTucTieuDiemParameterBuilder(bool ignoreCase, bool useAnd) : base(ignoreCase, useAnd) { }

		#endregion Constructors
	}

	#endregion TinTucTieuDiemParameterBuilder
} // end namespace
